//
//  DeleteCardCheckController.m
//  HuLaQuan
//
//  Created by hok on 1/21/16.
//  Copyright © 2016 Jianghao. All rights reserved.
//

#import "DeleteCardCheckController.h"

#import "BankCardListViewController.h"

#import "DeleteCardEngine.h"
@interface DeleteCardCheckController ()

@property (nonatomic, strong) DeleteCardEngine *deleteCardEngine;

@end

@implementation DeleteCardCheckController
- (DeleteCardEngine *)deleteCardEngine
{
    if (!_deleteCardEngine) {
        _deleteCardEngine = [[DeleteCardEngine alloc] init];
    }
    return _deleteCardEngine;
}
//-(NSString *)finish:(NSString *)pwd{
//    NSLog(@"haha %@",pwd);
//    
//    
//    if ([self.navigationController.viewControllers[1] isKindOfClass:[BankCardListViewController class]]) {
//        [self.navigationController popToViewController:self.navigationController.viewControllers[1] animated:YES];
//    }
//    
//    return pwd;
//}
- (void)confirmPayPasswordFinish
{
    [YuNetworkStatusUtilities showProgressMessage:NETWORK_LOADING];
    [self.deleteCardEngine deleteCardWithID:self.passwordAndInfos[@"cardId"]];
}
#pragma mark - Call Back
- (void)deleteCardFinish:(NSNotification*) notification
{
    
    [YuNetworkStatusUtilities dismissHUD];
    NSDictionary *messageDic = [notification object];//获取到传递的对象
    if ([messageDic[@"isSuccess"] boolValue]) {
        
        if ([self.navigationController.viewControllers[1] isKindOfClass:[BankCardListViewController class]]) {
            [self.navigationController popToViewController:self.navigationController.viewControllers[1] animated:YES];
        }
    }else{
        [self showNetWorkError:messageDic[@"message"]];
        
    }
    
}

#pragma mark - Controller Life Cycle
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deleteCardFinish:) name:@"DeleteCardFinish" object:nil];
    
}

- (void)viewWillDisappear:(BOOL)animated
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"DeleteCardFinish" object:nil];
    [super viewWillDisappear:YES];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
